    ;^Z80^
    TERMINAL:
                    EXTERNAL  BELL,CD_STAT,KBSTAT,KBREAD,KEYCLICK,CHR_OUT
                    EXTERNAL  U_STAT,CHR_IN,HANDLE_CHAR
    ; init the screen and stuff
                    CALL    BELL
    MAIN_LOOP:
    ; see if we're still online
                    CALL    CD_STAT
                    JP      Z,CARRIER_LOST
    ;
                    CALL    KBSTAT
                    OR      A
                    JR      Z,MAIN_1        ; No char yet
                    CALL    KBREAD
    ;
                    CALL    KEYCLICK
                    CALL    CHR_OUT       ; Send out to modem
    ; Get a key from modem
    MAIN_1:
                    CALL    U_STAT
                    JR      Z,NO_CHAR_PRESENT ; No characters today
                    CALL    CHR_IN          ; Read it
                    CALL    HANDLE_CHAR     ; Out to screen
    NO_CHAR_PRESENT:
                    JP      MAIN_LOOP       ; More abuse
    ;
    ;
    CARRIER_LOST:
                    RET                     ; Time to go away now.